package day07;

import java.util.Random;
import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        //1)猜数字案例
        /*
        Scanner scan = new Scanner(System.in);
        int num = (int) (Math.random()*100+1);
        System.out.println(num);
        while (true){
            System.out.println("猜吧！");
            int guess = scan.nextInt();
            if (guess>num){
                System.out.println("猜大了!");
            }else if (guess<num){
                System.out.println("猜小了！");
            }else {
                System.out.println("恭喜你猜对了！");
                break;
            }
        }

         */
        /*
        Scanner scan = new Scanner(System.in);
        int num = (int) (Math.random()*100+1);
        System.out.println(num);
        while (true){
            System.out.println("猜吧！");
            int guess = scan.nextInt()；
            if(guess>num){
                System.out.println("猜大了！");
            }else if (guess<num){
                System.out.println("猜小了！");
            }else {
                System.out.println("恭喜你猜对了！");
                break;
            }
        }

         */

        /*
        Scanner scan = new Scanner(System.in);
        int num = (int) (Math.random()*100+1);
        System.out.println(num);
        while (true){
            System.out.println("猜吧！");
            int guess = scan.nextInt();
            if (guess>num){
                System.out.println("猜大了！");
            }else if (guess<num){
                System.out.println("猜小了！");
            }else {
                System.out.println("恭喜你猜对了！");
                break;
            }
        }

         */


        //2)生成验证码
        /*
        String code = generateVeriCode(4);
        System.out.println("验证码："+code);

         */

        /*
        String code = generateVeriCode(5);
        System.out.println("验证码："+code);

         */
        /*

        String code = generateVeriCode(6);
        System.out.println("验证码：" + code);

         */




        //3)素数面试题
        /*
        for (int num = 2;num<=100;num++){
            boolean flag = true;
            for (int i = 2;i<=num/2;i++){
                if (num%i==0){
                    flag = false;
                    break;
                }
            }
            if (flag){
                System.out.println(num+"\t");
            }
        }

         */


        /*
        for (int num = 2;num<=100;num++){
            boolean flag = true;
            for (int i =2;i<=num/2;num++){
                if (num%i==0){
                    flag = false;
                }
            }
            if (flag){
                System.out.println(num+"\t");
            }
        }

         */

        /*
        for (int num = 2;num<=100;num++){
            boolean flag = true;
            for (int i =2;i<=num/2;num++){
                if (num%i==0){
                    flag = false;
                }
            }
            if (flag){
                System.out.println(num+"\t");
            }
        }

         */

        /*
        for (int num =2;num<=100;num++){
            boolean flag = true;
            for (int i =2;i<=num;i++){
                if (num%i==0){
                    flag =false;
                }
            }
            if (flag){
                System.out.println(num+"\t");
            }
        }

         */





        //4)机票价格
        /*

        Scanner scan = new Scanner(System.in);
        System.out.println("请输入机票原价：");
        double price = scan.nextDouble();
        System.out.println("请输入月份：");
        int month = scan.nextInt();
        System.out.println("请选择舱位：1.头等舱 2.商务舱 3.经济舱");
        int type = scan.nextInt();

        double finalPrice = calAirPrice(price,month,type);
        if (finalPrice!=-1){
            System.out.println("机票的最终价格为："+finalPrice);
        }

         */

        /*
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入机票原价：");
        double price = scan.nextDouble();
        System.out.println("请输入月份：");
        int month = scan.nextInt();
        System.out.println("请选择舱位：1.头等舱 2.商务舱 3.经济舱");
        int type = scan.nextInt();

        double finalPrice = calAirPrice(price,month,type);
        if (finalPrice!=-1){
            System.out.println("最终价格为"+finalPrice);
        }

         */
        /*
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入机票原价：");
        double price = scan.nextDouble();
        System.out.println("请输入月份");
        int month = scan.nextInt();
        System.out.println("请选择舱位");
        int type = scan.nextInt();

        double finalPrice = calAirPrice(price,month,type);
        if (finalPrice!=-1){
            System.out.println("机票最终价格为："+finalPrice);
        }

         */




        //5)评委打分，平均分
        /*
        double[]scores = enterData();
        double avg = calAvg(scores);
        System.out.println("平均分为："+avg);

         */
        /*
        double[]scores = enterData();
        double avg = calAvg(scores);
        System.out.println("平均分为"+avg);

         */

















    }

    /*
    public static String generateVeriCode(int len){
        String code = "";
        char[] chs = {'a','b','c','d','e','f','g','h','i','j','k',
                      'l','m','n','o','p','q','r','s','t','u','v',
                      'w','x','y','z','A','B','C','D','E','F','G',
                      'H','I','J','K','L','M','N','O','P','Q','R',
                      'S','T','U','V','W','X','Y','Z','0','1','2',
                      '3','4','5','6','7','8','9'};
        Random rand = new Random();
        for (int i = 1;i<=len;i++){
            int index = rand.nextInt(chs.length);
            code += chs[index];
        }
        return  code;
    }

     */
    /*
    public static String generateVeriCode(int len) {
        String code = "";
        char[] chs = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k',
                'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
                'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
                'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
                'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2',
                '3', '4', '5', '6', '7', '8', '9'};
        Random rand = new Random();
        for (int i = 1;i<=len;i++){
            int index = rand.nextInt(chs.length);
            code += chs[index];
        }
        return code;

    }

     */
    /*

    public static String generateVeriCode(int len) {
        String code = "";
        char[] chs = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k',
                'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
                'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
                'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
                'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2',
                '3', '4', '5', '6', '7', '8', '9'};
        Random rand = new Random();
        for (int i = 1; i <= len; i++) {
            int index = rand.nextInt(chs.length);
            code += chs[index];
        }
        return code;
    }

     */
    /*

    public static double calAirPrice(double price,int month,int type){
        double finalPrice = 0.0;
        if (month<1 || month>12){
            System.out.println("月份输入错误");
            return -1;
        }
        if (type<1 || type>3){
            System.out.println("舱位输入错误");
            return -1;
        }
        if (month>=5 && month<=10){
            switch (type){
                case 1:
                    finalPrice = price*0.9;
                    break;
                case 2:
                    finalPrice = price*0.85;
                    break;
                case 3:
                    finalPrice = price*0.8;
                    break;
            }
        }else {
            switch (type){
                case 1:
                    finalPrice = price*0.7;
                    break;
                case 2:
                    finalPrice = price*0.65;
                    break;
                case 3:
                    finalPrice = price*0.6;
                    break;
            }
        }
        return  finalPrice;

    }

     */
    /*

    public static double calAirPrice(double price,int month,int type){
        double finalPrice = 0.0;
        if (month<1 || month>12){
            System.out.println("月份输入错误");
            return -1;
        }
        if(type<1 || type>3){
            System.out.println("舱位输入错误");
            return -1;
        }
        if(month>=5 && month<=10){
            switch (type){
                case 1:
                    finalPrice = price*0.9;
                    break;
                case 2:
                    finalPrice = price*0.85;
                    break;
                case 3:
                    finalPrice = price*0.8;
                    break;
            }

        }else {
            switch (type){
                case 1:
                    finalPrice = price*0.7;
                    break;
                case 2:
                    finalPrice = price*0.65;
                    break;
                case 3:
                    finalPrice = price*0.6;
                    break;
            }
        }
        return finalPrice;
    }

     */

    /*
    public static double calAirPrice(double price,int month, int type){
        double finalPrice = 0.0;
        if (month<1 || month>12){
            System.out.println("月份输入错误");
            return -1;
        }
        if (type<1 || type>3){
            System.out.println("舱位输入错误");
            return -1;
        }
        if (month>=5 && month<=10){
            switch (type){
                case 1:
                    finalPrice = price*0.9;
                    break;
                case 2:
                    finalPrice = price*0.85;
                    break;
                case 3:
                    finalPrice = price*0.8;
                    break;
            }
        }else{
            switch (type){
                case 1:
                    finalPrice = price*0.7;
                    break;
                case 2:
                    finalPrice = price*0.65;
                    break;
                case 3:
                    finalPrice = price*0.6;
                    break;
            }
        }
        return finalPrice;

    }

     */

    /*
    public static double[] enterData(){
        Scanner scan = new Scanner(System.in);
        double[] scores = new double[6];
        for (int i =0;i<scores.length;i++){
            System.out.println("请录入第"+(i+1)+"个评委的分数");
            scores[i] = scan.nextDouble();
        }
        return scores;
    }
    public static double calAvg(double[]scores){
        double total = calTotal(scores);
        double avg = total/(scores.length-2);
        return avg;
    }

    public static double calTotal(double[] scores){
        double total = 0.0;
        double max = scores[0];
        double min = scores[0];
        for (int i =0;i<scores.length;i++){
            if (scores[i]>max){
                max = scores[i];
            }
            if (scores[i]<min){
                min = scores[i];
            }
            total += scores[i];
        }
        return  total-max-min;
    }

     */

    /*
    public static double[] enterData(){
        Scanner scan = new Scanner(System.in);
        double[] scores = new double[6];
        for (int i =0;i<scores.length;i++){
            System.out.println("请输入第"+(i+1)+"个评委的分数");
            scores[i] = scan.nextDouble();
        }
        return scores;

    }
    public static double calAvg(double[]scores){
        double total = calTotal(scores);
        double avg = total/(scores.length-2);
        return avg;
    }
    public static double calTotal(double[]scores){
        double total = 0.0;
        double max = scores[0];
        double min = scores[0];
        for (int i = 0;i<scores.length;i++){
            if (scores[i]>max){
                max = scores[i];
            }
            if (scores[i]<min){
               min = scores[i];
            }
            total += scores[i];
        }
        return total-max-min;
    }

     */

}
